﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LaughingDog.GameObjects;
using Microsoft.Xna.Framework;

namespace LaughingDog.Components
{
    /// <summary>
    /// Base class for everything that can be attached to a GameObject.
    /// </summary>
    public class Component : Object
    {
        private GameObject mGameObject = null;        
            
        /// <summary>
        /// The GameObject this component is attached to. A Component will always be attached to a GameObject.
        /// </summary>
        public GameObject GameObject { get { return mGameObject; } }

        /// <summary>
        /// A list of all Components attached to the GameObject that this Component is attached to.
        /// </summary>
        public List<Component> Components { get { return GameObject.Components; } }

        /// <summary>
        /// A list of all IDrawableComponents attached to the GameObject that this Component is attached to.
        /// </summary>
        public List<IDrawableComponent> DrawableComponents { get { return GameObject.DrawableComponents; } }

        /// <summary>
        /// The Transform attached to the GameObject that this Component is attached to.        
        /// </summary>        
        public Transform Transform { get { return GameObject.Transform; } }

        /// <summary>
        /// The RigidBody attached to the GameObject that this Component is attached to. Null if there isn't one attached.
        /// </summary>
        public RigidBody RigidBody { get { return GameObject.RigidBody; } }

        /// <summary>
        /// A list of all ConstantForces attached to the GameObject that this Component is attached to.
        /// </summary>
        public List<ConstantForce> ConstantForces { get { return GameObject.ConstantForces; } }

        /// <summary>
        /// The Collider attached to the GameObject that this Component is attached to. Null if there isn't one attached.
        /// </summary>
        public Collider Collider { get { return GameObject.Collider; } }

        /// <summary>
        /// The Camera attached to the GameObject that this Component is attached to. Null if there isn't one attached.
        /// </summary>
        public Camera Camera { get { return GameObject.Camera; } }

        /// <summary>
        /// The Renderer attached to the GameObject that this Component is attached to. Null if there isn't one attached.
        /// </summary>
        public Renderer Renderer { get { return GameObject.Renderer; } }

        /// <summary>
        /// A list of all Animations attached to the GameObject that this Component is attached to.
        /// </summary>
        public List<Animation> Animations { get { return GameObject.Animations; } }

        /// <summary>
        /// A list of all AudioSources attached to the GameObject that this Component is attached to.
        /// </summary>
        public List<AudioSource> Audio { get { return GameObject.Audio; } }

        /// <summary>
        /// A Text component attached to the GameObject that this Component is attached to.        
        /// </summary>
        public Text Text { get { return GameObject.Text; } }

        /// <summary>
        /// A list of all Scripts attached to the GameObject that this Component is attached to.
        /// </summary>
        public List<Script> Scripts { get { return GameObject.Scripts; } }

        /// <summary>
        /// Creates a new instance of a Component.
        /// </summary>
        /// <param name="gameObject">The GameObject the Component will be attached to.</param>
        public Component(GameObject gameObject)
        {
            mGameObject = gameObject;
        }

        /// <summary>
        /// Updates this Component.
        /// </summary>
        public virtual void Update()
        {

        }
    }
}
